#!/bin/bash

./mk.config.pl
. config.sh

echo "$DB_HOST:$DB_PORT:$DB_NAME:$DB_USER:$DB_PASS" > $PGPASS
chmod go-rwx $PGPASS

if [ -z $1 ]; then
	echo 'usage: db.query.sh <script.sql>'
	exit 1
fi

export PGPASS
psql -h $DB_HOST -d $DB_NAME -U $DB_USER -f $1
rm -f $PGPASS
